package com.example.firstapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;

public class OpenedClass extends Activity implements OnClickListener, OnCheckedChangeListener {

	TextView tv1, tv2;
	Button bReturn;
	RadioGroup rgSelection;
	String getBread ,setData;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.send);
		initialize();

		/*Bundle bundle = getIntent().getExtras();
		getBread = bundle.getString("key");
		tv1.setText(getBread);*/
	}

	private void initialize() {
		tv1 = (TextView) findViewById(R.id.tvQuestion);
		tv2 = (TextView) findViewById(R.id.tvTest);
		bReturn = (Button) findViewById(R.id.bReturn);
		rgSelection = (RadioGroup) findViewById(R.id.rgAnswers);
		bReturn.setOnClickListener(this);
		rgSelection.setOnCheckedChangeListener(this);
	}

	@Override
	public void onClick(View v) {
        Intent intent=new Intent();
        Bundle bundle=new Bundle();
        bundle.putString("answer", setData);
        intent.putExtras(bundle);
        setResult(RESULT_OK, intent);
        finish();
	}

	@Override
	public void onCheckedChanged(RadioGroup group, int checkedId) {
		switch (checkedId) {
		case R.id.rCrazy:
			setData = "Probably";
			break;
		case R.id.rSexy:
			setData = "Definetily";
			break;
		case R.id.rboth:
			setData = "Spot On!";
			break;
		}
       tv2.setText(setData);
	}
}
